package 力扣日常刷题.木22一月.第16天0128;

import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;

/**
 * @author 帅小伙
 * @date 2022/1/28
 * @description
 */
public class Demo17字符串简单旅行终点站 {


    public String destCity(List<List<String>> paths) {
        Set<String> from = new HashSet<>();
        Set<String> to = new HashSet<>();
        paths.forEach(path ->{
            from.add(path.get(0));
            to.add(path.get(1));
        });
        to.removeAll(from);
        Optional<String> first = to.stream().limit(1).findFirst();
        return first.get();
    }

}
